{% load static %}
{% load blog_tags %}
{% load comment_tags %}
<!doctype html>
<html lang="en">
<head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="referrer" content="origin">
    <!-- TDK and ICO -->
    <title>{% block head_title %}{% endblock %}_{{ site_end_title }}</title>
    {% block metas %}
        <meta name="description" content="{{ site_description }}">
        <meta name="keywords" content="{{ site_keywords }}">
    {% endblock %}
    <link rel="shortcut icon" href="{% static 'blog/img/favicon.ico' %}" type="image/x-icon"/>
    <!-- Bootstrap and font-awesome CSS -->
    <link href="{% static 'blog/bootstrap/4.3.1/css/bootstrap.min.css' %}" rel="stylesheet">
    <link href="{% static 'blog/font-awesome/4.7.0/css/font-awesome.min.css' %}" rel="stylesheet">
    <script src="{% static 'blog/js/headroom.min.js' %}"></script>
    <!-- blog CSS -->
    <link href="{% static 'blog/css/base.css' %}?v={{ static_version.css_blog_base }}" rel="stylesheet">
    {#设置默认的全局变量stop_headroom，默认会自动隐藏导航，如果要固定导航可以在top-file里面重新设置这个变量为true#}
    <script>var stop_headroom = false;</script>
    {% block top-file %}{% endblock %}
    <!--根据cookies判断是否启用暗色主题-->
    {% if not request.COOKIES.toggleTheme %}
        {% now_hour as hour %}
        {% if hour < 6 or hour > 18 %}
            <link id="theme-css-dark" href="{% static 'blog/css/night.css' %}?v={{ static_version.css_blog_night }}"
                  rel="stylesheet">
        {% endif %}
    {% else %}
        {% if request.COOKIES.toggleTheme == "dark" %}
            <link id="theme-css-dark" href="{% static 'blog/css/night.css' %}?v={{ static_version.css_blog_night }}"
                  rel="stylesheet">
        {% endif %}
    {% endif %}
</head>
<body>
<!--导航开始-->
{% include 'blog/tags/navbar.html' %}
<!--导航结束-->

<!--消息块-->
{% if messages %}
    <div class="container">
        {% for message in messages %}
            <div class="alert {% if message.tags %}alert-{{ message.tags }}{% else %}alert-secondary{% endif %} alert-dismissible rounded-6 fade show"
                 role="alert">
                {{ message }}
                <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
        {% endfor %}
    </div>
{% endif %}

<!--切换主题按钮-->
<div class="text-center" id="change-theme" title="切换主题">
    {% if not request.COOKIES.toggleTheme %}
        {% now_hour as hour %}
        {% if hour < 6 or hour > 18 %}
            <i class="fa fa-sun-o"></i>
        {% else %}
            <i class="fa fa-moon-o"></i>
        {% endif %}
    {% else %}
        {% if request.COOKIES.toggleTheme == "dark" %}
            <i class="fa fa-sun-o"></i>
        {% else %}
            <i class="fa fa-moon-o"></i>
        {% endif %}
    {% endif %}
</div>
<!--回到顶部按钮-->
<div class="text-center" id="to-top" title="回到顶部"><i class="fa fa-arrow-up"></i></div>

<!--主要内容块-->
<main>{% block base_content %}{% endblock %}</main>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="{% static 'blog/js/jq/3.3.1/jquery.min.js' %}"></script>
<!--js cookie 插件-->
<script src="{% static 'blog/js/js.cookie.min.js' %}?v=20191123.12"></script>
<script src="{% static 'blog/js/popper.min.js' %}"></script>
<script src="{% static 'blog/bootstrap/4.3.1/js/bootstrap.min.js' %}"></script>
<script>
    $(function () {
        if (stop_headroom === false) {
            const myElement = document.querySelector(".blog-navbar");
            const headroom = new Headroom(myElement);
            headroom.init()
        }
    });
</script>
<script>var css_night_version = "{{ static_version.css_blog_night }}";</script>
<script src="{% static 'blog/js/base.js' %}?v={{ static_version.js_blog_base }}"></script>
{% if user.is_authenticated %}
    <script>
        const msgs = {% get_notifications_count user 'false' %};
        if (msgs > 0) {
            let _record = 0;
            const myTitle = document.title;

            function titleBlink() {
                _record++;
                if (_record % 2) {
                    document.title = '【 】' + myTitle
                } else {
                    document.title = '【新消息】' + myTitle
                }
                setTimeout("titleBlink()", 500)
            }

            titleBlink()
        }
    </script>
{% endif %}
{% block end_file %}{% endblock %}
<footer class="container-fluid mt-4 py-0">
    <div class="card-body text-center px-0 f-14">
        {% if 51la %}
            {{ 51la|safe }}
            {% if user.is_superuser %}
                <i class="fa fa-line-chart mx-1"></i>
                <a href="https://v6.51.la/user/application" target="_blank">站长统计</a>
            {% endif %}
        {% endif %}
        <p class="mb-0">
            <a href="http://beian.miit.gov.cn/" target="_blank">{{ beian }}</a>
            {% if cnzz_protocol %}|&nbsp;{{ cnzz_protocol|safe }}{% endif %}
            <span class="with-love"><i class="fa fa-heart"></i></span>
            {% with web_update_time="" %}
                <span id="web-day"
                        {% if web_update_time %}
                      title="最近更新时间：{{ web_update_time }}"
                        {% endif %}>网站已续航&nbsp;{{ site_create_date }}</span>
            {% endwith %}
        </p>
        <p class="card-text mb-1">Copyright&nbsp;&copy;&nbsp;<span
                id="year-info">{{ site_create_year }}-{{ this_year }}</span>
            <a href="https://github.com/Hopetree" target="_blank" title="博客作者的Github">Hopetree</a>.&nbsp;Powered&nbsp;by&nbsp;Django.
            <a href="{% url 'django.contrib.sitemaps.views.sitemap' %}" target="_blank">Sitemap</a>
        </p>
    </div>
</footer>
</body>
</html>